package Panel;
/**
 * Created by win10 on 2017/6/13.
 */

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

class ClickAction implements ActionListener{
	//数组status[1]表示圆的状态，status[2]表示三角形的状态；status[3]表示四边形；status[4]和status[5]表示加减号；
	static int [] drawStatus=new int[15];  //用数组表示当前要画的图形的类型  “1”  表示为需选择的 “0” 表示取消； 
	static int [] colorStatus=new int [10];
	static int penSize=5;
	
	
    public void actionPerformed(ActionEvent event){
    	if(event.getActionCommand()=="〇"){
    		selecDrawtStatus(1);
    		 System.out.println("1");
    		
    	}else if(event.getActionCommand()=="△"){
    		selecDrawtStatus(2);
    		 System.out.println("2");
    		
    	}else if(event.getActionCommand()=="□"){
    		selecDrawtStatus(3);
    		 System.out.println("3");
    		
    	}else if(event.getActionCommand()=="-"){
    		selecDrawtStatus(4);
    		penSize-=1;
    		 System.out.println("4");
    	}else if(event.getActionCommand()=="+"){
    		selecDrawtStatus(5);
    		penSize+=1;
    		 System.out.println("5");
    		
    	}else if(event.getActionCommand()=="移动图形"){
    		selecDrawtStatus(6);
    		System.out.println("6");
    		
    	}
    	else if(event.getActionCommand()=="旋转图形"){
    		selecDrawtStatus(7);
   		 System.out.println("7");
    	}
    	else if(event.getActionCommand()=="缩放图形"){
    		selecDrawtStatus(8);
   		 System.out.println("8");
    	}
    	else if(event.getActionCommand()=="显示图形"){
    		selecDrawtStatus(9);
    		DrawPanel.shapes.showShape();
    		System.out.println("9");
    	}else if(event.getActionCommand()=="红色"){
    		//10 设置红色
    		selectColorStatus(1);
    		System.out.println("红色");
    	}else if(event.getActionCommand()=="黄色"){
    		//10 设置红色
    		selectColorStatus(2);
    		System.out.println("黄色");
    	}else if(event.getActionCommand()=="绿色"){
    		//10 设置红色
    		selectColorStatus(3);
    		System.out.println("绿色");
    	}
    }
    public void selecDrawtStatus(int n){  //输入号修改的的序号对status数组进行修改
    	for(int i=0;i<drawStatus.length;i++){
    		drawStatus[i]=0;
    	}
    	drawStatus[n]=1;
    	
    }
    public void selectColorStatus(int n){
    	//colorStatus[1,2,3,]依次为红，黄，绿；
    	for(int i=0;i<colorStatus.length;i++){
    		colorStatus[i]=0;
    	}
    	colorStatus[n]=1;
    }
}
